package com.zqu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zqu.pojo.MarketingOpportunities;
import com.zqu.service.MarketingOpportunitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("marketingopportunities")
public class MarketingOpportunitiesController {

    @Autowired
    MarketingOpportunitiesService marketingOpportunitiesService;

    @RequestMapping("selctmarketingopportunitieslist")
    @ResponseBody
    public PageInfo<MarketingOpportunities> selectList(Integer pageNo,Integer pageSize){
        if(pageNo==null){
            pageNo=1;
        }
        if (pageSize==null){
            pageSize=5;
        }
        PageHelper.startPage(pageNo,pageSize);
        List<MarketingOpportunities> list = marketingOpportunitiesService.selectList(new MarketingOpportunities());
        PageInfo<MarketingOpportunities> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @RequestMapping("insertmarketingopportunities")
    @ResponseBody
    public boolean insert(MarketingOpportunities marketingOpportunities){
        return marketingOpportunitiesService.insertMarketingOpportunities(marketingOpportunities);
    }

    @RequestMapping("updatemarketingopportunities")
    @ResponseBody
    public boolean update(MarketingOpportunities marketingOpportunities){
        return marketingOpportunitiesService.updateMarketingOpportunities(marketingOpportunities);
    }

    @RequestMapping("deletemarketingopportunities")
    @ResponseBody
    public boolean delete(long id){
        return marketingOpportunitiesService.deleteMarketingOpportunities(id);
    }

    @RequestMapping("deletemarketingopportunitiesbyids")
    @ResponseBody
    public boolean deleteByIds(String[] ids){
        return marketingOpportunitiesService.deleteMarketingOpportunitiesByIds(ids);
    }
}
